import 'dart:ffi';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:xiaomi_shop/app/api/api.dart';
import 'package:xiaomi_shop/app/services/xhttp.dart';

class RegisterStep1Controller extends GetxController {
  final TextEditingController textEditingController = TextEditingController();
  @override
  void onInit() {
    super.onInit();
  }

  @override
  void onReady() {
    super.onReady();
  }

  @override
  void onClose() {
    super.onClose();
  }

  Future<bool> sendCode() async {
    var response = await XHttp.getInstance()
        .post(Api.sendCode, {"tel": textEditingController.text});
    print(response);
    if (response != null) {
      Result result = response as Result;
      if (result.data["success"]) {
        // 测试，将验证码粘贴在粘贴板上
        Clipboard.setData(ClipboardData(text: result.data["code"]));
        return true;
      } else {
        return false;
      }
    } else {
      return false;
    }
  }
}
